package io.renren.controller;

import io.renren.common.utils.Result;
import io.renren.service.WxJsapiPayService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Map;

/**
 * @ClassName ApiWxJsApiPayController
 * @Description TODO
 * @Author Jll
 * @Date 2024/6/23 13:38
 * @Version 1.0
 */
@RestController
@RequestMapping("/api/wxjsapi")
@Slf4j
public class ApiWxJsapiPayController {

    @Resource
    private WxJsapiPayService wxJsapiPayService;

    /**
     * 合作伙伴小程序下单
     * @return
     * @throws Exception
     */
    @PostMapping("/partnerPaymentsJsapiPay")
    public Result<Map<String, Object>> partnerPaymentsJsapiPay() throws Exception {
        log.info("发起合伙人partnerPaymentsJsapiPay支付请求 v3");
        return wxJsapiPayService.partnerPaymentsJsapiPay();
    }

    /**
     * 合作伙伴商户订单号查询订单
     * @return
     * @throws Exception
     */
    @GetMapping("/queryOrderByOutTradeNo")
    public Result<Map<String, Object>> queryOrderByOutTradeNo(@RequestParam String outTradeNo) throws Exception {
        Map<String, Object> map = wxJsapiPayService.queryOrderByOutTradeNo(outTradeNo);
        return new Result().ok(map);
    }
}
